package com.bhs.sansonglogistics.ui.adapter;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.bean.MenuBean;
import com.chad.library.adapter.base.BaseQuickAdapter;

import com.chad.library.adapter.base.BaseViewHolder;


import java.util.List;

//菜单适配器
public class MenuAdapter extends BaseQuickAdapter<MenuBean, BaseViewHolder> {


    public MenuAdapter(int layoutResId, @Nullable List<MenuBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, MenuBean menuBean) {
        View view = baseViewHolder.getView(R.id.view);
        if (view != null) {
            view.setVisibility(menuBean.isShow() ? View.VISIBLE : View.GONE);
        }
        baseViewHolder.setText(R.id.tv_name, menuBean.getMenuName()).setVisible(R.id.tv_name, menuBean.getMenuIcon() != 0);
        baseViewHolder.setImageResource(R.id.iv_icon, menuBean.getMenuIcon()).setVisible(R.id.iv_icon, menuBean.getMenuIcon() != 0);
    }
}
